package org.zhadoop.stream.cql.semanticanalyzer.analyzecontext;

import java.util.List;
import java.util.TreeMap;

import org.zhadoop.stream.api.streams.Schema;
import org.zhadoop.stream.cql.exception.SemanticAnalyzerException;
import org.zhadoop.stream.cql.semanticanalyzer.analyzecontext.expressiondesc.JoinExpressionDesc;
import org.zhadoop.stream.cql.semanticanalyzer.analyzecontext.expressiondesc.PropertyValueExpressionDesc;
import org.zhadoop.stream.cql.semanticanalyzer.parser.context.FromClauseContext;
import org.zhadoop.stream.cql.semanticanalyzer.parser.context.ParseContext;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;

/**
 * from 子句语义分析内容
 * @author zwd
 *
 */
public class FromClauseAnalyzeContext extends AnalyzeContext{

	
	/**
	 * 输入的schema
	 * 如果是包含了join，那么就包含多个输入
	 */
	private List<Schema> inputSchemas = Lists.newArrayList();
	
	private List<String> inputStreams = Lists.newArrayList();
	
	/**
	 * Join 表达式
	 */
	private JoinExpressionDesc joinexpression;
	
	
	/**
	 * 子查询关系映射
	 * 流名称-->子查询解析结果
	 */
	private TreeMap<String, InsertAnalyzeContext> subQueryForStream = Maps.newTreeMap();
	
	private TreeMap<String, CreateStreamAnalyzeContext> subQuerySchemas = Maps.newTreeMap();
	
	private TreeMap<String, PropertyValueExpressionDesc> combineConditions = Maps.newTreeMap();
	
	private String uniDirections;
	
	private FromClauseContext fromContext = null;
	
	
	public List<Schema> getInputSchemas() {
		return inputSchemas;
	}

	public void setInputSchemas(List<Schema> inputSchemas) {
		this.inputSchemas = inputSchemas;
	}

	public List<String> getInputStreams() {
		return inputStreams;
	}

	public void setInputStreams(List<String> inputStreams) {
		this.inputStreams = inputStreams;
	}

	public JoinExpressionDesc getJoinexpression() {
		return joinexpression;
	}

	public void setJoinexpression(JoinExpressionDesc joinexpression) {
		this.joinexpression = joinexpression;
	}

	public TreeMap<String, InsertAnalyzeContext> getSubQueryForStream() {
		return subQueryForStream;
	}

	public void setSubQueryForStream(TreeMap<String, InsertAnalyzeContext> subQueryForStream) {
		this.subQueryForStream = subQueryForStream;
	}

	public TreeMap<String, CreateStreamAnalyzeContext> getSubQuerySchemas() {
		return subQuerySchemas;
	}

	public void setSubQuerySchemas(TreeMap<String, CreateStreamAnalyzeContext> subQuerySchemas) {
		this.subQuerySchemas = subQuerySchemas;
	}

	public TreeMap<String, PropertyValueExpressionDesc> getCombineConditions() {
		return combineConditions;
	}

	public void setCombineConditions(TreeMap<String, PropertyValueExpressionDesc> combineConditions) {
		this.combineConditions = combineConditions;
	}

	public String getUniDirections() {
		return uniDirections;
	}

	public void setUniDirections(String uniDirections) {
		this.uniDirections = uniDirections;
	}

	public FromClauseContext getFromContext() {
		return fromContext;
	}

	public void setFromContext(FromClauseContext fromContext) {
		this.fromContext = fromContext;
	}

	@Override
	public void setParseContext(ParseContext parseContext) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void validateParseContext() throws SemanticAnalyzerException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public List<Schema> getCreatedSchemas() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return null;
	}
	
	/**
	 * 添加输入流
	 * @param streamName
	 */
	public void addInputStream(String streamName){
		inputStreams.add(streamName);
	}

}
